home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / ip / trace / tcpdump-2.2.1 / bpf / sunif / if_le.c-sunos4.1-patch next >
Encoding:
Text File  |  1992-03-30  |  2.1 KB  |  81 lines

  1. *** /tmp/,RCSt1a10663    Tue Mar 31 08:03:31 1992
  2. --- if_le.c    Tue Mar 31 08:00:30 1992
  3. ***************
  4. *** 40,45 ****
  5. --- 40,50 ----
  6.   
  7.   #include <sundev/mbvar.h>
  8.   
  9. + #include "bpfilter.h"
  10. + #if NBPFILTER > 0
  11. + #include "../net/bpf.h"
  12. + #endif
  13.   #include <sunif/if_lereg.h>
  14.   #include <sunif/if_levar.h>
  15.   
  16. ***************
  17. *** 264,269 ****
  18. --- 269,278 ----
  19.       /* Do hardware-independent attach stuff. */
  20.       ether_attach(&es->es_if, unit, "le",
  21.           leinit, leioctl, leoutput, lereset);
  22. + #if NBPFILTER > 0
  23. +     bpfattach(&es->es_bpf, &es->es_if, DLT_EN10MB, 
  24. +           sizeof(struct ether_header));
  25. + #endif
  26.       /*
  27.        * attach interrupts and dma vectors
  28.        */
  29. ***************
  30. *** 1028,1033 ****
  31. --- 1037,1049 ----
  32.               }
  33.           } while (m = m->m_next);
  34.   
  35. + #if NBPFILTER > 0
  36. +         {
  37. +             struct le_softc *le = &le_softc[unit];
  38. +             if (le->es_bpf)
  39. +                 bpf_mtap(le->es_bpf, m0);
  40. +         }
  41. + #endif
  42.           /*
  43.            * t points to the next free tmd.
  44.            */
  45. ***************
  46. *** 1384,1389 ****
  47. --- 1400,1431 ----
  48.           return;
  49.       }
  50.   
  51. + #if NBPFILTER > 0
  52. +         /*
  53. +          * If bpf is listening on this interface, let it see the packet 
  54. +      * before we pass it up to higher evel protocols.  
  55. +      *
  56. +      * Note that BPF doesn't currently (and hopefully never will)
  57. +      * work for trailer-encapsulated packets.  We just ignore them.
  58. +          */
  59. +         if (es->es_bpf && off == 0) {
  60. +                 bpf_tap(es->es_bpf, (u_char *)header, 
  61. +             length + sizeof(struct ether_header));
  62. +         /*
  63. +          * If we are in promiscuous mode, we return if this
  64. +          * packet isn't for us.  This prevents NIT from seeing
  65. +          * any promiscuous packets when there is a BPF listener.
  66. +          * The IFF_PROMISC test isn't necessary but saves the
  67. +          * bcmp() calls; it's probably worthwhile.
  68. +          */
  69. +         if ((es->es_if.if_flags & IFF_PROMISC) &&
  70. +             bcmp(header->ether_dhost.ether_addr_octet,
  71. +              es->es_enaddr.ether_addr_octet, 6) != 0 &&
  72. +             bcmp(header->ether_dhost.ether_addr_octet,
  73. +              etherbroadcastaddr.ether_addr_octet, 6) != 0)
  74. +             return;
  75. +     }
  76. + #endif
  77.       /*
  78.        * Pull packet off interface.  Off is nonzero if packet has
  79.        * trailing header; copy_to_mbufs will then force this header
  80.